#include <QCoreApplication>


#include "process.h"

bool start();


int main(int argc, char *argv[])
{
    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForLocale(codec);
    QCoreApplication a(argc, argv);
    std::cout<<"欢迎来到《单词快打》，冲！"<<std::endl;

    Process::init();

    bool flag = true;
    while(flag)
    {
        flag = start();
    }
    return a.exec();
}

bool start()
{
    bool flag = true;
    std::string in;
    std::cout << "请输入操作指令：/rush:开冲 /config:配置词典 /clear:清屏 /exit:退出" << std::endl;
    std::cout << "请输入（按回车执行）：";
    std::cin >> in;
    if(in == "/rush") {
        Process::rush();
    }
    else if(in == "/config") {
        Process::config();
    }
    else if(in == "/clear") {
        Process::clear();
    }
    else if(in == "/exit") {
        flag = false;
    }
    else {
        std::cout << "请输入正确的指令，如 '/rush'" << std::endl;
    }
    return flag;
}
